package com.example.perpetualcalendar.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.example.perpetualcalendar.R;
import com.example.perpetualcalendar.databinding.ItemHistoyBinding;
import com.example.perpetualcalendar.domain.entity.History;

import java.util.List;

public class MyAdapter extends BaseAdapter {

    private List<History.ResultDTO> resultDTOS;
    private ItemHistoyBinding binding;

    public MyAdapter(List<History.ResultDTO> resultDTOS) {
        this.resultDTOS = resultDTOS;
    }

    @Override
    public int getCount() {
        return resultDTOS==null ? 0 : resultDTOS.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_histoy, parent, false);
        History.ResultDTO dto = resultDTOS.get(position);
        binding.dateTime.setText(dto.getDate()+"  "+dto.getDay());
        binding.dateContent.setText(dto.getTitle());
        return binding.getRoot();
    }

}
